#include <bits/stdc++.h>
// 2025/02/04
// tag: 
// Author: Zhang Muen
using namespace std;

using int64 = int64_t;

struct Item{
    int w, v;
}Wave[100001];

int n, cnt, W, dp[100001];

signed main()
{
    cin >> n >> W;
    for (int i = 1; i <= n; i++){
        int v, w, m;
        cin >> v >> w >> m;
        for (int j = 1; j <= m; j <<= 1){
            cnt++;
            Wave[cnt].v = j * v;
            Wave[cnt].w = j * w;
            m -= j;
        }
        if (m){
            cnt++;
            Wave[cnt].v = m * v;
            Wave[cnt].w = m * w;
        }
    }
    for (int i = 1; i <= cnt; i++)
        for (int j = W; j >= Wave[i].w; j--)
            dp[j] = max(dp[j], dp[j - Wave[i].w] + Wave[i].v);
    cout << dp[W] << endl;
    return 0;
}